package com.zxn.xiaoran.model.http;


import com.zxn.xiaoran.model.api.ApiFactory;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by zxn on 2019/7/29.
 */
public class BasicParamsInterceptor implements Interceptor {


    @Override
    public Response intercept(Chain chain) throws IOException {

        String url = chain.request().url().uri().toString();
        String sign = ApiFactory.getInstance().signRequest(url);

        Request.Builder builder = chain.request()
                .newBuilder()
                .url(chain.request().url())
                .header("Content-Type", "application/json")
                .header("Host", "rsf.qbox.me")
                .header("Connection", "keep-alive")
                .header("Authorization", sign);

        return chain.proceed(builder.build());
    }
}
